package ch09;

import java.io.File;
import java.util.Scanner;

class _40_ScannerEx3 {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(new File("c:/save/data40.txt"));
		Scanner sc2 = null;
		int cnt = 0;
		int totalSum = 0;		
		String line = "";
		int sum = 0;
		while (sc.hasNextLine()) {
			line = sc.nextLine();
			sc2 = new Scanner(line).useDelimiter(",");
			while (sc2.hasNextInt()) sum += sc2.nextInt();
			System.out.println(line + ", sum = " + sum);
			totalSum += sum;
			cnt++;
		}
		System.out.println("Line: " + cnt + ", Total: " + totalSum);
	}
}
/*
[data40.txt]
100,100,100
200,200,200
300,300,300
--
100,100,100, sum = 300
200,200,200, sum = 600
300,300,300, sum = 900
Line: 3, Total: 1800
*/